package models


type Service struct {
	Model
	Content string `json:"content"`
	I18N	string `json:"i18n" gorm:"column:i18n"`
	Show	int8   `json:"show"`
}


func ExistServiceByID(id int) bool {
	var service Service
	db.Select("id").Where("id = ?", id).First(&service)
	return service.ID > 0
}

func GetServices() (services []Service) {
	db.Find(&services)
	return
}

func AddService(content, i18n string, show int8) bool {
	db.Create(&Service{
		Content: content,
		I18N: i18n,
		Show: show,
	})
	return true
}

func DeleteService(id int) bool {
	db.Where("id = ?", id).Delete(&Service{})
	return true
}

func UpdateService(id int, data interface{}) bool {
	db.Model(&Service{}).Where("id = ?", id).Updates(data)
	return true
}